//
//  SXPstatusModel.swift
//  weibo
//
//  Created by shixinPeng on 16/3/1.
//  Copyright © 2016年 shixinPeng. All rights reserved.
//

import UIKit

class SXPstatusModel: NSObject {
    ///id	int64	微博ID
    var id: Int = 0
    ///  created_at	string	微博创建时间
    var created_at: String?
    /// text	string	微博信息内容
    var text: String?
    ///source	string	微博来源
    var source: String?
    /// 用户个人信息
    var user: SXPstatusesUserModel?
    
    ///reposts_count	int	转发数
    var reposts_count: Int = 0
    ///comments_count	int	评论数
    var comments_count: Int = 0
    ///attitudes_count	int	表态数
    var attitudes_count: Int = 0
    
    ///retweeted_status	object	被转发的原微博信息字段，当该微博为转发微博时返回 详细
    var retweeted_status: SXPstatusModel?
    
    /// pic_urls图片数组
    var pic_urls:[SXPpictureModel]?
    
    
    init(Dict: [String: NSObject]) {
        
       super.init()
        //字典转模型
        setValuesForKeysWithDictionary(Dict)
        
        if let userDict = Dict["user"] as? [String: NSObject]{
            
            user = SXPstatusesUserModel(dict: userDict)
        }
        if let retweetDict = Dict["retweeted_status"] as? [String: NSObject]{
            retweeted_status = SXPstatusModel(Dict: retweetDict)
        }
        /*
        配图数据是一个数组
        先取出这个数组.
        实例化一个模型数组,
        然后遍历数据数组,
        把模型添加到模型数组中去

        */
        //获取数组
        if let pic_urlsArray = Dict["pic_urls"] as? [[String: NSObject]]{
            //实例化模型数组
            pic_urls = [SXPpictureModel]()
           //遍历数据数组
            for info in pic_urlsArray {
                pic_urls?.append(SXPpictureModel(dict: info))
            }
            
        }
    
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    
}
